package com.pengheng.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pengheng.entity.Order;
import com.pengheng.service.IOrderService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private IOrderService orderService;

    @RequestMapping("/list")
    public Object list() {
        LambdaQueryWrapper<Order> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.orderByAsc(Order::getId);
        return orderService.list(queryWrapper);
    }

    @RequestMapping("/save")
    public Object save(Integer age, String name, Long userId) {
        Order entity = new Order();
        entity.setAge(age);
        entity.setName(name);
        entity.setUserId(userId);
        return orderService.save(entity);
    }

}
